import { DeclareState } from '@/api/modules/types/data.query'

export const rules = {
  inspectContent: {
    required: true,
    message: '请输入通过或驳回理由',
    trigger: 'change',
  },
  inspectName: {
    required: true,
    message: '请输入审批人姓名',
    trigger: 'change',
  },
  inspectTel: {
    required: true,
    message: '请输入审批人联系方式',
    trigger: 'change',
  },
}

export const Declarerules = {
  ReportContent: {
    required: true,
    message: '请输入申报理由',
    trigger: 'change',
  },
  ReportName: {
    required: true,
    message: '请输入申报人姓名',
    trigger: 'change',
  },
  ReportTel: {
    required: true,
    message: '请输入申报人联系方式',
    trigger: 'change',
  },
}

export interface InspectForm {
  declareID: string
  inspectContent: string
  inspectName: string
  inspectTel: string
}

export interface DeclareForm {
  Files: any[]
  StartTime: string
  EndTime: string
  EntName: string
  ReuseName: string
  ReuseObjID: string
  ReportContent: string
  ReportName: string
  ReportTel: string
  ReportTime: string
  DeclareStateName: string
  DeclareStateID: number
  ProduceObjID: string
  ProduceName: string
  ReusePartName: string
  ReusePartObjID: string
}

export function useInitForm(): { formData: Ref<InspectForm>, initForm: () => void } {
  const getData = (): InspectForm => ({
    declareID: '',
    inspectContent: '',
    inspectName: '',
    inspectTel: '',
  })
  const formData = ref<InspectForm>(getData())

  const initForm = () => {
    formData.value = getData()
  }

  return { formData, initForm }
}

export function statusType(ID: number) {
  switch (ID) {
    case DeclareState.Inspecting:
      return 'warning'
    case DeclareState.Completed:
      return 'success'
    case DeclareState.DeclareFail:
      return 'danger'
  }
}

export function useInitDeclareForm(): { formData: Ref<DeclareForm>, initForm: () => void } {
  const getData = (): DeclareForm => ({
    DeclareStateID: 0,
    DeclareStateName: '',
    EndTime: '',
    EntName: '',
    Files: [],
    ReportContent: '',
    ReportName: '',
    ReportTel: '',
    ReportTime: '',
    ReuseName: '',
    ReuseObjID: '',
    StartTime: '',
    ProduceName: '',
    ProduceObjID: '',
    ReusePartName: '',
    ReusePartObjID: '',
  })
  const formData = ref<DeclareForm>(getData())

  const initForm = () => {
    formData.value = getData()
  }

  return { formData, initForm }
}
